#pragma once
#include <myFs/fsinterface.h>
#include <myFs/simpleFShelper.h>
//#include "fscache.h"

namespace myFs {
namespace basic {
class SimpleFS : public FSinterface {
  public:
    ~SimpleFS();
    SimpleFS(::std::string str = "dumpfile");

  public:
    int open(std::string const& path) override;
    int readdir(std::string const& path, std::vector<DirEntry>& dir) override;
    int write(std::string const& path, char const* buf, size_t size, size_t off) override;
    int read(std::string const& path, char* buf, size_t size, size_t off) override;
    int rename(std::string const& path1, std::string const& path2) override;
    int rmdir(std::string const& path) override;
    int mkdir(std::string const& path) override;
    int mknod(std::string const& path) override;
    int getattr(std::string const& path, Inode& stat) override;
    int unlink(std::string const& path) override;
    int releasedir(std::string const& path) override;

  private:
    void   getFatherDirAndName(std::string const& path, std::string& fatherpath, std::string& filename);
    size_t dirLookup(size_t inum, std::string const& filename);
  private:
    SimpleFShelper m_helper;
};
}  // namespace basic
}  // namespace myFs